<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>列表</title>
<link href="/assets/bui/css/bs3/dpl.css" rel="stylesheet">
<link href="/assets/bui/css/bs3/bui.css" rel="stylesheet">
</head>
<body>
  <div class="demo-content">
  
    <div class="row">
      <div class="span24 doc-content">
        <ul class="breadcrumb">
          <li>
            <a href="#">首页</a> <span class="divider">/</span>
          </li>
          <li>
            <a href="#">管理</a> <span class="divider">/</span>
          </li>
          <li class="active">列表</li>
        </ul>
        <form class="form-panel" action="post">
          <div class="panel-title">
            <span>
              <label>报名日期：</label><input type="text" class="calendar" /> <label>至</label> <input type="text" class="calendar" />
            </span>
            <span>
              <label>上阶段审核日期：</label><input type="text" class="calendar" /> <label>至</label> <input type="text" class="calendar" />
            </span>
          </div>
          <ul class="panel-content">
            <li>
              <select name="">
                <option>省份</option>
              </select>
              <select name="">
                <option>城市</option>
              </select>
              <select name="">
                <option>商品类型</option>
              </select>
              <select name="">
                <option>平台类型</option>
              </select>
              <select name="">
                <option>是否在商品池</option>
              </select>
              <select name="">
                <option>是否看样子</option>
              </select>
              <select name="">
                <option>是否已审核</option>
              </select>
            </li>
            <li>
              <select name="">
                <option>一级类目</option>
              </select>
              <input type="text"/>
              <button type="submit" class="button button-primary">查询>></button>
            </li>
          </ul>
        </form>
	        <div class="row">
		      <div class="span24">
		        <div id="grid">
		          
		        </div>
		        <div id="bar"></div>
		      </div>
		    </div>
      </div>
    </div> 
  <script src="/assets/bui/js/jquery-1.8.1.min.js"></script>
  <script src="/assets/bui/js/seed-min.js"></script>  
  <script src="/assets/bui/js/config.js"></script>
  <script src="/assets/bui/js/bui.js"></script>
<script type="text/javascript">
	BUI.use('bui/calendar',function(Calendar){
	    var datepicker = new Calendar.DatePicker({
	        trigger:'.calendar',
	        autoRender : true
	      });
	  });
	var Grid = BUI.Grid,
    Toolbar = BUI.Toolbar,
    Data = BUI.Data;
    var Grid = Grid,
  Store = Data.Store,
  columns = [
	  #for(col : cols)
	  {title : '#(col.column_comment)',dataIndex :'#(col.column_name)'},
	  #end
	  {title : '操作',width : 100,dataIndex:'id',renderer : function(value,obj){
          if(obj.operation){//如果是操作行
            return '<a href="#" class="grid-command btn-add"><i class="icon icon-ok"></i> 确认添加</a>'
          }
          return '<a href="edit?id='+value+'"><span class="grid-command btn-edit">编辑</span></a>'+
          '<a href="view?id='+value+'"><span class="grid-command btn-edit">详情</span></a>'+
          '<a  onclick="del('+value+')" class="grid-command btn-del">删除</a>'
	  }}
  ];

var store = new Store({
    url : 'index.json',
    root:'list',//数据字段
    totalProperty:'count',//记录字段
    proxy : {//设置请求相关的参数
        method : 'post',
        //dataType : 'jsonp', //返回数据的类型
        limitParam : 'limit', //一页多少条记录
        pageIndexParam : 'page', //页码
        pageStart : 1,//分页从1开始
        saveDataParam:'list'
    },
    autoLoad:true,
    remoteSort : true,
    pageSize:10    // 需要在store中 配置pageSize
  }),
  grid = new Grid.Grid({
    render:'#grid',
    columns : columns,
    emptyDataTpl : '<div class="centered"><img alt="Crying" src="http://img03.taobaocdn.com/tps/i3/T1amCdXhXqXXXXXXXX-60-67.png"><h2>查询的数据不存在</h2></div>',
    store : store
  });
var bar = new Toolbar.NumberPagingBar({
  render : '#bar',
  elCls : 'pagination pull-right',
  store : store
});
bar.render();
grid.render();

function del(id){
    BUI.Message.Confirm('确认删除该条记录吗？',function(){
    	$.ajax({url:'del.json?id='+id,success:function(data){
    		if(data.code==200){
    			BUI.Message.Alert('已删除!','success');
    		setTimeout(function(){
                location.reload();
              },1000);
    		}
    		}
    	})
    },'question');
  }
</script>
  </div>
</body>
</html>